home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
owners.fr_
/
owners.fr
Wrap
Text File
|
1995-07-06
|
5KB
|
167 lines
VERSION 4.00
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Ownership"
ClientHeight = 3090
ClientLeft = 690
ClientTop = 1875
ClientWidth = 6750
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 3495
Left = 630
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 6750
Top = 1530
Width = 6870
Begin VB.CommandButton cmdClose
Caption = "&Close"
Height = 495
Left = 3660
TabIndex = 5
Top = 2100
Width = 1755
End
Begin VB.CommandButton cmdSave
Caption = "&Save Owner"
Height = 555
Left = 1200
TabIndex = 4
Top = 2100
Width = 1755
End
Begin VB.ListBox lstTables
Height = 1395
Left = 3660
TabIndex = 1
Top = 360
Width = 2535
End
Begin VB.ListBox lstUsers
Height = 1395
Left = 360
Sorted = -1 'True
TabIndex = 0
Top = 360
Width = 2535
End
Begin VB.Label Label2
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "Tables and queries:"
Height = 195
Left = 3660
TabIndex = 3
Top = 120
Width = 1695
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "Users:"
Height = 195
Left = 360
TabIndex = 2
Top = 120
Width = 555
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
#If Win32 Then
Private Declare Function GetWindowsDirectory Lib "Kernel32" _
Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
#Else
Private Declare Function GetWindowsDirectory Lib "Kernel" _
(ByVal lpBuffer As String, _
ByVal nSize As Integer) As Integer
#End If
Private db As DATABASE
Private Sub Form_Load()
Dim myUser As String, myPass As String
Dim i As Integer
Dim winDir As String * 128
Dim dirLen As Integer
Dim dbName As String
' Get the Windows directory and set the INI path.
dirLen = GetWindowsDirectory(winDir, 128)
If dirLen = 0 Then Error 32767
DBEngine.IniPath = Left$(winDir, dirLen) & "\VBDBHT.INI"
' Set the user and passwords for initial login.
myUser = "Admin"
myPass = "theboss"
DBEngine.DefaultUser = myUser
DBEngine.DefaultPassword = myPass
' Get the database name and open the database.
dbName = DataPath() & "\CHAPTER.09\ORDERS.MDB" ' DataPath() is in READINI.BAS
Set db = DBEngine.Workspaces(0).OpenDatabase(dbName)
' Fill the list boxes on the form.
FillUserList
FillTableList
End Sub
Sub FillUserList()
Dim usr As User
For Each usr In DBEngine.Workspaces(0).Users
If UCase$(usr.Name) <> "CREATOR" And UCase$(usr.Name) <> "ENGINE" Then
lstUsers.AddItem usr.Name
End If
Next
End Sub
Sub FillTableList()
Dim doc As Document
For Each doc In db.Containers("Tables").Documents
If Left$(doc.Name, 4) <> "MSys" Then lstTables.AddItem doc.Name
Next
End Sub
Private Sub lstTables_Click()
Dim i As Integer
lstUsers.ListIndex = -1
For i = 0 To lstUsers.ListCount - 1
If lstUsers.List(i) = db.Containers("Tables").Documents(lstTables.TEXT).Owner Then
lstUsers.ListIndex = i
Exit For
End If
Next i
End Sub
Private Sub cmdSave_Click()
Dim doc As Document
On Error GoTo SaveError
db.Containers("Tables").Documents(lstTables.TEXT).Owner = lstUsers.TEXT
Exit Sub
SaveError:
MsgBox Err.Description & " (" & Err.Number & ")"
End Sub
Private Sub cmdClose_Click()
End
End Sub